package com.base.cn.platform.os.controller.course.cou.small;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.common.utils.ObjectUtils;
import com.base.cn.platform.os.common.utils.course.CourseType;
import com.base.cn.platform.os.common.utils.web.WebUtils;
import com.base.cn.platform.os.service.course.cou.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 后台小班课Controller
 *
 * @author HangDaLi
 * @create 2020-03-07
 */
@Controller
@RequestMapping("/admin/course/small")
public class AdminSmallCourseConTroller extends AdminBaseController {

    @Autowired
    private CourseService courseService;

    /**
     * 初始化小班课列表
     *
     * @return 列表页面
     */
    @RequestMapping("/smallCourseList")
    public String smallCourseList(Model model) {
        return resultPage("/course/cou/small/small_course_list");
    }


    /**
     * 获取小班课数据
     *
     * @param params
     * @param currentPage 当前页码
     * @return 列表页面
     */
    @RequestMapping("/ajaxSmallCourseList")
    public String ajaxSmallCourseList(Model model,
                                      @RequestBody Map<String, Object> params,
                                      @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage) {
        params.put("courseTypeKey", CourseType.COURSE_TYPE_SMALL.getKey());
        params.put("type", 1);
        Map<String, Object> dataMap = courseService.findWebCoursePage(params, currentPage, 12, false, true, true, true, false);
        model.addAttribute("dataMap", dataMap);
        return resultPage("/course/cou/small/ajax_course_small_list");
    }

} 